<template>
	<view style="width:100vw; height:100vh;" class="bg-white">
		<view class="flex flex-direction" style="background: linear-gradient(45deg, #35B5FF 0%, #007AFF 100%); width: 100%; height: 100%;">
			<!-- 顶部按钮 -->
			<view class="flex justify-between padding-top padding-bottom" style="font-size: 50rpx;">
				<text class="text-white cuIcon-mail margin-left" @click="$Router.push({name: 'chatList'})"></text>
				<text class=" text-white cuIcon-scan margin-right"></text>
			</view>
			<!-- 个人信息栏 -->
			<view class="flex justify-between text-white ">
				<!-- 头像、姓名 -->
				<view class="align-center">
					<view class="cu-avatar lg round margin-left margin-right-sm" :style="'background-image:url('+avatar+');'"></view>
					<text style="font-size: 34rpx; font-weight: 600;">{{username}}</text>
				</view>
				<!-- 个人中心 -->
				<view class="flex align-center">
					<navigator url="/pages/mine/myCenter" style="font-size: 28rpx;">个人中心 <text class=" cuIcon-right margin-right margin-left-xs"></text></navigator>
				</view>
			</view>
			
			<!-- <view class="bg-white" style="width: 100%;position: fixed;bottom: 0;border-radius: 60rpx 60rpx 0 0;"> -->
			<view class="bg-white flex-sub flex flex-direction" style="margin-top: 30rpx;width: 100%;border-radius: 60rpx 60rpx 0 0;">
				<view class="flex justify-center align-center" style="margin-top: 48rpx;">
					<text style="font-size: 36rpx;font-weight: bold;color: #1591FF;line-height: 48rpx;">学问宝会员</text>
				</view>
				<view class="flex justify-around" style="margin-top: 48rpx;">
					<view v-for="(item, index) in vipTypeList" @click="current=index" :key="index" :class="current==index ? 'price-box-selected' : 'price-box'" class="flex flex-direction justify-center align-center">
						<view>{{item.name}}</view>
						<view :class="current==index ? 'price-selected' : 'price'">
							￥ <text style="font-size: 48rpx; line-height: 64rpx;">{{item.price}}</text>
						</view>
					</view>
				</view>
				<view @click="goToPay()" class="flex justify-center align-center" style="margin:68rpx 32rpx 8rpx 32rpx;height: 96rpx;background-color: #007AFF;border-radius: 12rpx;">
					<text style="font-size: 32rpx;font-weight: bold;color: #FFFFFF;line-height: 44rpx;">
						立即购买
					</text>
				</view>
				<view class="flex justify-center align-center" style="margin:20rpx 240rpx 0 240rpx;height: 72rpx;background-color: #F3FAFC;border-radius: 36rpx;">
					<text style="font-size: 28rpx;color: rgba(0, 0, 0, 0.25);line-height: 40rpx;">
						会员服务协议
					</text>
				</view>
				<view class="flex-sub flex flex-direction justify-around" style="margin-top: 20rpx; padding: 0 32rpx;">
					<view style="font-size: 32rpx;font-weight: bold;color: #333333;line-height: 48rpx;">
						学问宝会员尊享特权
					</view>
					<view class="flex align-center">
						<view style="width: 80rpx; height: 80rpx; background-color: #007AFF;"></view>
						<view class="flex flex-direction justify-between" style="margin-left: 16rpx;">
							<text style="font-size: 28rpx;font-weight: bold;color: #333333;line-height: 48rpx;">畅看精品课程</text>
							<text style="font-size: 20rpx;color: #999999;line-height: 32rpx;">300+精品课程免费看</text>
						</view>
					</view>
					<view class="flex align-center">
						<view style="width: 80rpx; height: 80rpx; background-color: #007AFF;"></view>
						<view class="flex flex-direction justify-between" style="margin-left: 16rpx;">
							<text style="font-size: 28rpx;font-weight: bold;color: #333333;line-height: 48rpx;">畅听精品书籍</text>
							<text style="font-size: 20rpx;color: #999999;line-height: 32rpx;">海量书籍免费听</text>
						</view>
					</view>
					<view class="flex align-center">
						<view style="width: 80rpx; height: 80rpx; background-color: #007AFF;"></view>
						<view class="flex flex-direction justify-between" style="margin-left: 16rpx;">
							<text style="font-size: 28rpx;font-weight: bold;color: #333333;line-height: 48rpx;">畅看文献论文</text>
							<text style="font-size: 20rpx;color: #999999;line-height: 32rpx;">海量论文免费看</text>
						</view>
					</view>
					<view class="flex align-center">
						<view style="width: 80rpx; height: 80rpx; background-color: #007AFF;"></view>
						<view class="flex flex-direction justify-between" style="margin-left: 16rpx;">
							<text style="font-size: 28rpx;font-weight: bold;color: #333333;line-height: 48rpx;">免费图书租赁</text>
							<text style="font-size: 20rpx;color: #999999;line-height: 32rpx;">精品书籍免费租</text>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { mapActions } from "vuex";
	export default {
		data() {
			return {
				userid: this.$store.getters.userid,
				username: this.$store.getters.username,
				avatar: this.$store.getters.avatar,
				vipTypeList: [],
				
				current: 0,
			}
		},
		onLoad() {
			this.$http.get('/ucenter/vip/getAllVipType').then((res) => {
				let data = res.data;
				if(data.success) {
					this.vipTypeList = data.result;
				}else {
					this.$tip.alert(data.message)
				}
			}).catch((err) => {
				console.log(err);
			})
		},
		methods: {
			...mapActions([ "savePage"]),
			goToPay() {
				let vipTypeId = this.vipTypeList[this.current].id;
				this.$http.post(`/eduorder/order/createVipOrder/${vipTypeId}`).then((res) => {
					let data = res.data;	//data中的result是订单编号outTradeNo
					if(data.success) {
						// console.log("outTradeNo", data.result)
						this.$Router.push({
							name: 'orderConfirm',
							params: {
								outTradeNo: data.result
							}
						})
					}
				}).catch((err) => {
					console.log(err);
				})
			}
		}
	}
</script>

<style>
	.price-box{
		width: 200rpx;
		height: 160rpx;
		background: #F6FAFD;
		border-radius: 10rpx;
		border: 4rpx solid #EEEEEE;
		font-size: 28rpx;
		font-weight: bold;
		color: rgba(0, 0, 0, 0.85);
		line-height: 48rpx;
	}
	.price-box-selected{
		width: 200rpx;
		height: 160rpx;
		background: rgba(12, 135, 255, 0.1);
		border-radius: 10rpx;
		border: 4rpx solid #0E89FF;
		font-size: 28rpx;
		font-weight: bold;
		color: rgba(0, 0, 0, 0.85);
		line-height: 48rpx;
	}
	.price{
		color: rgba(0, 0, 0, 0.45);
	}
	.price-selected{
		color: #1591FF;
	}
</style>
